extends WindowDialog

onready var _textUid=$textUid
onready var _textName=$textName
onready var _btnJoin=$btnJoin
onready var _textDanMu=$textDanMu
onready var _btnDanMu=$btnDanMu
onready var _btnNextSound=$btnNextSound
onready var _btnRandomJoin=$btnRandomJoin
onready var _textRank=$textRank
onready var _btnRank=$btnRank
onready var _btnTeXie=$btnTeXie



# Called when the node enters the scene tree for the first time.
func _ready():
	_btnJoin.connect("pressed",self,'_onBtnJoin')
	_btnDanMu.connect("pressed",self,'_onBtnDanMu')
	_btnNextSound.connect("pressed",self,'_onBtnNextSound')
	_btnRandomJoin.connect("pressed",self,'_onBtnRandomJoin')
	_btnRank.connect("pressed",self,'_onBtnRank')
	_btnTeXie.connect("pressed",self,'_onBtnTeXie')
func _onBtnJoin():
	var uid=int(_textUid.text)
	var uName=_textName.text
	PlayerManager.addPlayer(uid,uName)
	pass
func _onBtnDanMu():
	var uid=_textUid.text
	var player=PlayerManager.getPlayer(uid)
	if !player:
		return
	var actor=player.actor as Actor
	if !actor:
		return
	actor.showDialogue(_textDanMu.text)
	pass
func _onBtnNextSound():
	SoundManger.nextSound()
func _onBtnTeXie():
	var cameraCtl=G.cameraCtl as CameraCtl
	var uid=_textUid.text
	var player=PlayerManager.getPlayer(uid)
	if !player:
		return
	var actor=player.actor
	if !actor:
		return
	cameraCtl.teXie(actor)
	pass
func _onBtnRandomJoin():
	var uid=int(rand_range(0,100))
	var uName='玩家'+str(uid)
	PlayerManager.addPlayer(uid,uName)
	pass
func _onBtnRank():
	var s=_textRank.text
	var arr=s.split(',')
	DjManager.onRankChangeUid(arr)

func _on_btnPaoHuoChe_pressed():
	var uid=_textUid.text
	var player=PlayerManager.getPlayer(uid)
	if !player:
		return
	var actor=player.actor as Actor
	if !actor:
		return
	actor.startPaoHuoChe()
	pass 


func _on_bigAdd_pressed():
	var uid=_textUid.text
	var actor=PlayerManager.getActor(uid)
	if actor:
		actor.big+=0.1



func _on_bigReduce_pressed():
	var uid=_textUid.text
	var actor=PlayerManager.getActor(uid)
	if actor:
		actor.big-=0.1



func _on_rotating_pressed():
	var uid=_textUid.text
	var actor=PlayerManager.getActor(uid) as Actor
	if actor:
		actor.isRotating=true
	pass # Replace with function body.


func _on_stopRotationg_pressed():
	var uid=_textUid.text
	var actor=PlayerManager.getActor(uid) as Actor
	if actor:
		actor.isRotating=false
	pass # Replace with function body.
